<template>
    <checkDetail
            v-if="detailVisible"
            @changeDetailVisible="changeDetailVisible"
            :detail="detailObj"
    ></checkDetail>
    <div class="project zy-content" v-else>
        <div class="title">
            <span>精度检测任务管理</span>
            <div class="icon">
        <span class="creatBtnright" @click="exportMaintainTask" v-if="checkBtnPermission.dcmAcctestTaskExport">
          <span><Icon type="ios-cloud-download-outline" color="#187BDB" /></span>
          <span class="rightbtn">导出检测任务</span>
        </span>
            </div>
        </div>
        <div class="searchBox">
            <Form label-position="right" :label-width="90" class="search-form">
                <Row>
                    <Col span="4">
                        <FormItem label="检测人：">
                            <Input type="text" clearable v-model="searchParams.operater" :placeholder="`${$t('common.inputInfo')}`" class="inputBorder" :maxlength="32"></Input>
                        </FormItem>
                    </Col>
                    <Col span="4">
                        <FormItem label="检测状态：">
                            <Select v-model="searchParams.taskStatus" filterable clearable :placeholder="`${$t('common.inputInfo')}`" >
                                <Option v-for="(item,index) of category" :value="item.key" :key="index">{{ item.name }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
<!--                    <Col span="4">-->
<!--                        <FormItem label="检测方式：">-->
<!--                            <Select v-model="searchParams.mainType" filterable clearable :placeholder="`${$t('common.inputInfo')}`">-->
<!--                                <Option v-for="(item,index) of cycle" :value="item.key" :key="index">{{ item.name }}</Option>-->
<!--                            </Select>-->
<!--                        </FormItem>-->
<!--                    </Col>-->
                    <Col span="4">
                        <FormItem label="检测计划：">
                            <Select
                                    v-model="searchParams.planId"
                                    filterable
                                    clearable
                                    :placeholder="`${$t('common.inputInfo')}`"
                                    :remote-method="getCenterList"
                                    :loading="loading"
                            >
                                <Option v-for="(item,index) of planList" :value="item.value" :key="index">{{ item.label }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="6">
                       <FormItem :label="`${$t('fault.FunctionalLocation')}:`" >
                            <Cascader clearable :data="orgList" v-model="searchParams.orgCode" :placeholder="`${$t('common.selectInfo')}`" change-on-select></Cascader>
                        </FormItem>
                    </Col>
                    <Col span="4">
                        <FormItem label="设备类别：">
                            <Select
                                    v-model="searchParams.categoryId"
                                    filterable
                                    clearable
                                    :placeholder="`${$t('common.selectInfo')}`"
                            >
                                <Option
                                        v-for="(item) of centerList"
                                        :value="item.value"
                                        :key="item.value"
                                >{{ item.label }}</Option
                                >
                            </Select>
                        </FormItem>
                    </Col>
<!--                    <Col span="4">-->
<!--                        <FormItem :label="`${$t('maintenance.EquipmentNo')}:`" >-->
<!--                            <Input type="text" clearable v-model="searchParams.deviceMId" :placeholder="`${$t('common.inputInfo')}`" class="inputBorder" :maxlength="32"></Input>-->
<!--                        </FormItem>-->
<!--                    </Col>-->
<!--                    <Col span="4">-->
<!--                        <FormItem :label="`${$t('ledger.EquipmentNo')}:`" >-->
<!--                            <Input type="text" clearable v-model="searchParams.deviceNo" :placeholder="`${$t('common.inputInfo')}`" class="inputBorder" :maxlength="32"></Input>-->
<!--                        </FormItem>-->
<!--                    </Col>-->
                    <Col span="7">
                        <FormItem label="任务时间：">
                            <DatePicker
                                    :value="dateTimeRange"
                                    type="datetimerange"
                                    placement="bottom-end"
                                    :placeholder="`${$t('common.selectInfo')}`"
                                    @on-change="handleRangeChange"
                            />
                        </FormItem>
                    </Col>
                    <Col span="5" style="display: flex; justifyContent: space-around">
                        <Button type="primary" @click="changeNum" v-if="checkBtnPermission.dcmAcctestTaskList">{{$t('common.Query')}}</Button>
                        <Button type="primary" shape="circle" @click="handleBatchDispatch" v-if="ids.length && checkBtnPermission.dcmAcctestTaskBatchDistribute">批量分配</Button>
                        <Button type="primary" shape="circle" @click="handleBatchDelete" v-if="ids.length && checkBtnPermission.dcmAcctestTaskDeleteBatch">批量删除</Button>
                    </Col>
                </Row>
            </Form>
        </div>
        <div class="tableContent">
            <Table ellipsis ref="selection" :columns="columns" :data="data"  @on-selection-change="onSelectChange">
                <template slot-scope="{ row }" slot="action">
                    <Poptip title="" :transfer="true" placement="bottom">
                        <span class="operationBtn" v-if="row.taskStatus == 1 && checkBtnPermission.dcmAcctestTaskExportFile">{{$t('common.Export')}}</span>
                        <div slot="content">
                            <Button @click="exportFile(row,'A')">导出A系列</Button>
                            <Button @click="exportFile(row,'G')" style="marginLeft: 10px">导出G系列</Button>
                        </div>
                    </Poptip>
                    <span class="operationBtn" @click="checkResult(row)" v-if="row.taskStatus == 1 && checkBtnPermission.dcmAcctestTaskImportFile">检测结果</span>
                    <span class="operationBtn" @click="edit(row)" v-if="checkBtnPermission.dcmAcctestTaskQueryById">{{$t('common.Check')}}</span>
                    <span class="operationBtn" @click="allot(row)" v-show="row.taskStatus == 0 && checkBtnPermission.dcmAcctestTaskDistribute">分配</span>
                    <span class="operationBtn" @click="deleteRow(row)" v-if="checkBtnPermission.dcmAcctestTaskDelete">{{$t('common.Delete')}}</span>
                </template>
            </Table>
        </div>
        <div class="pageWrap">
            <Page :total="total" :page-size="pageSize" :page-size-opts="$variable.pageSizes" :current="pageNum" @on-change="changePageNum" @on-page-size-change="changePageSize" show-sizer show-total />
        </div>
        <Modal :mask-closable="false"
                v-model="delFaultCodeShowF"
                title=""
        >
            <Row class="enableContent">
                <Col span="24" class="enableContentInner">
                    <img width="95px" src="~images/event/del.png" alt="">
                </Col>
                <Col span="24" class="enableTips">
                    <span>删除后不会影响已经生成的检测任务，但不会继续生成任务，是否确认删除？</span>
                </Col>
            </Row>
            <div slot="footer">
                <Button type="default"  @click="delFaultCodeShowF = false">{{$t('common.Cancle')}}</Button>
                <Button type="primary" @click="deleteOk" :loading="delLoading">{{$t('maintenance.Confirmed')}}</Button>
            </div>
        </Modal>
        <!--    <Modal :mask-closable="false"-->
        <!--      v-model="allotVisible"-->
        <!--      width="1000"-->
        <!--      class="addModal"-->
        <!--      title="请分配点检人员"-->
        <!--      @on-ok="ok"-->
        <!--      @on-cancel="cancel"-->
        <!--    >-->
        <!--      <allotModal :list="list"></allotModal>-->
        <!--    </Modal>-->
        <signle-common-modal ref="signleCommonModal" @handleRefresh="handleRefresh"/>
        <Modal :mask-closable="false"
                v-model="resultVisible"
                title="检测结果"
                width="600"
                class="resultModal"
        >
            <Form class="formList" ref="resultForm" :model="formInline" :label-width="200">
                <FormItem label="A客户精度检测文件：" v-if="!formInline.fileNameG">
                    <Upload
                            :before-upload="beforeUploadA"
                            :show-upload-list="true"
                            type="drag"
                            action=""
                            style="width: 110px"
                    >
                        <Button type="primary" icon="ios-cloud-upload-outline">选择文件</Button>
                    </Upload>
                    <div class="uploadWrapper">
                        <span class="item-src">{{ formInline.fileNameA }}</span>
                        <Icon class="item-icon" type="ios-close" size="20" style="float:right;" @click="delFile(0)" v-if="formInline.fileNameA"></Icon>
                    </div>
                </FormItem>
                <FormItem label="G客户精度检测文件：" v-if="!formInline.fileNameA">
                    <Upload
                            :before-upload="beforeUploadG"
                            :show-upload-list="true"
                            type="drag"
                            action=""
                            style="width: 110px"
                    >
                        <Button type="primary" icon="ios-cloud-upload-outline">选择文件</Button>
                    </Upload>
                    <div class="uploadWrapper">
                        <span class="item-src">{{ formInline.fileNameG }}</span>
                        <Icon class="item-icon" type="ios-close" size="20" style="float:right;" @click="delFile(1)" v-if="formInline.fileNameG"></Icon>
                    </div>
                </FormItem>
            </Form>
            <div slot="footer">
                <Button type="default"  @click="handleCancel">{{$t('common.Cancle')}}</Button>
                <Button type="primary" :loading="uploadLoading"  @click="handleOk">{{$t('maintenance.Confirmed')}}</Button>
            </div>
        </Modal>

    </div>
</template>

<script>
    import fileDownload from 'js-file-download'
    import recursion from '../../../../util/recursion'
    // import checkDetail from './modal/checkDetail'
    import checkDetail from './modal/checkDetail'
    import signleCommonModal from "../../repair/modules/signleCommonModal";
    export default {
        name: "accuracyTask",
        components: {
            checkDetail,
            signleCommonModal
        },
        created() {
            let url = window.location.href.split('?')[1]; //获取url中"?"符后的字串
            let strs = url ? url.split("&") : [];
            let theRequest = new Object();
            for(let i = 0; i < strs.length; i ++) {
                theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);
            }
            this.searchParams.deviceMId = theRequest.deviceMId
            this.searchList()
            this.getOrgList()
            this.getDeviceList()
        },
        data() {
            return {
                taskId: '',
                delStatus: 0,
                delId: '',
                dispatchId: '',
                dispatchStatus: 0,
                total: 0,
                pageNum: 1,
                pageSize: 50,
                delFaultCodeShowF: false,//是否显示删除弹窗
                allotVisible: false,//是否显示删除弹窗
                detailVisible: false,
                resultVisible: false,
                loading: false,
                uploadLoading: false,
                delLoading: false,
                headers: {},
                searchParams: {},
                checkBtnPermission: {},
                detailObj: {},
                formInline: {
                    fileNameA: '',
                    fileNameG: '',
                },
                ids: [],
                pageSizeOption: [50, 100, 150, 200],
                list: [],
                planList: [],
                category: [
                    {name: '未分配', key: '0'},
                    {name: '未完成', key: '1'},
                    // {name: '待确认', key: '2'},
                    {name: '已完成', key: '3'},
                    {name: '已过期', key: '4'},
                ],
                cycle: [
                    {name: '定期保养', key: '1'},
                    {name: '计数', key: '2'},
                    {name: '计时', key: '3'},
                ],
                position: [{name: "全部", key: ""}],
                classification: [{name: "全部", key: ""}],
                columns: [
                    {key:'selection',type: 'selection',width: 60,align: 'center'},
                    {title: '任务状态', key: 'taskStatusText',minWidth: 110,
                        // render: (h, params) => {
                        //   if(params.row.categ=='待确认'){
                        //     return h('div', [
                        //       h('span', {style:{color:'red'}}, params.row.categ)
                        //     ]);
                        //     }else{
                        //       return h('div', [
                        //         h('span', params.row.categ)
                        //     ]);
                        //   }
                        //
                        // }
                    },
                    {title: '检测方式', key: 'acctestType',minWidth: 110},
                    {title: '触发间隔', key: 'intervalRate',minWidth: 110},
                    // {title: '累计生产时长', key: 'lastHours',width: 110},
                    // {title: '累计生产数量', key: 'lastYields',width: 110},
                    {title: '检测人', key: 'operater',minWidth: 200},
                    {title: '设备类别', key: 'categoryName',minWidth: 110},
                    // {title: '设备名称', key: 'deviceName',width: 130},
                    // {title: `${ this.$t('maintenance.EquipmentNo') }`, key: 'deviceMId',width: 110},
                    // {title: `${ this.$t('common.machineno') }`, key: 'deviceNo',minWidth: 200},
                    {title: '检测计划', key: 'planName',minWidth: 300},
                    {title: '功能位置', key: 'orgName',minWidth: 300},
                    {title: '任务开始时间', key: 'createTime',minWidth: 160},
                    {title: '检测开始时间', key: 'taskBeginTime',minWidth: 160},
                    {title: '检测结束时间', key: 'reviewTime',minWidth: 160},
                    {title: '检测时长', key: 'taskLength',minWidth: 160},
                    { title: `${ this.$t('maintenance.workinghours') }`, key: 'itemHours',minWidth: 160},
                    {title: '任务截止时间', key: 'taskEndTime',minWidth: 160},
                    // { title: `${ this.$t('maintenance.MaintenanceItem') }`, key: 'maintenanceProject',width: 160},
                    // {title: '保养方式', key: 'maintenanceMode',width: 120},
                    // { title: `${ this.$t('maintenance.Unit') }`, key: 'unit',width: 100},
                    // {title: `${ this.$t('maintenance.UpperLimit') }`, key: 'upper',width: 100},
                    // { title: `${ this.$t('maintenance.LowerLimit') }`, key: 'floor',width: 100},
                    // {title: '结果记录', key: 'objectRecord',width: 120},
                    // {title: `${ this.$t('maintenance.maintainresults') }`, key: 'maintenanceService',width: 120},
                    // {title: '确认人', key: 'reviewer',minWidth: 120},
                    // {title: '确认时间', key: 'reviewTime',minWidth: 160},
                    {title: `${ this.$t('common.operation') }`, slot: "action", minWidth: 400, align: 'center',fixed: 'right'}
                ],
                data: [],
                orgList: [],
                centerList: [],
                dateTimeRange: []
            }
        },
        mounted() {
            let itemList = JSON.parse(window.localStorage.getItem('USER_URI'))
            for(let item of itemList){
                if(item.code=="dcmAcctestTaskQueryById"){
                    this.checkBtnPermission.dcmAcctestTaskQueryById = true
                }
                if(item.code=="dcmAcctestTaskDistribute"){
                    this.checkBtnPermission.dcmAcctestTaskDistribute = true
                }
                if(item.code=="dcmAcctestTaskDelete"){
                    this.checkBtnPermission.dcmAcctestTaskDelete = true
                }
                if(item.code=="dcmAcctestTaskDeleteBatch"){
                    this.checkBtnPermission.dcmAcctestTaskDeleteBatch = true
                }
                if(item.code=="dcmAcctestTaskBatchDistribute"){
                    this.checkBtnPermission.dcmAcctestTaskBatchDistribute = true
                }
                if(item.code=="dcmAcctestTaskList"){
                    this.checkBtnPermission.dcmAcctestTaskList = true
                }
                if(item.code=="dcmAcctestTaskExport"){
                    this.checkBtnPermission.dcmAcctestTaskExport = true
                }
                if(item.code=="dcmAcctestTaskExportFile"){
                    this.checkBtnPermission.dcmAcctestTaskExportFile = true
                }
                if(item.code=="dcmAcctestTaskImportFile"){
                    this.checkBtnPermission.dcmAcctestTaskImportFile = true
                }

            }
        },
        methods: {
            /***********************获取基础数据**************************/
            getCenterList(query) {
                if (query !== '') {
                    this.loading = true
                    this.axios({
                        method: 'get',
                        url: '/dms/dcmAcctestDetail/queryPlans',
                        params: {
                            planName: query
                        }
                    }).then(res => {
                        if (res.code === 200) {
                            this.planList = res.data
                        } else {
                            this.$Message.warning(({content: res.msg, duration: 6, closable: true}));
                        }
                    }).finally(() => {
                        this.loading = false
                    })
                }else {
                    this.planList = []
                }

            },
            getOrgList() {
                this.axios({
                    method: 'get',
                    url: '/basic/organization/findListByToken',
                    params: {}
                }).then(res => {
                    if(res.code === 200){
                        const obj ={
                            label: 'name',
                            value: 'code',
                            children: 'children'
                        }
                        this.orgList = recursion.convertTree(res.data, obj)
                    }else{
                        this.$Message.warning(({content:res.msg,duration:6,closable:true}));
                    }
                })
            },
            getDeviceList() {
                this.axios({
                    method: 'get',
                    url: '/dms/dmsCategory/getSelectList',
                    params: {}
                }).then(res => {
                    if(res.code === 200){
                        this.centerList = res.data
                    }else{
                        this.$Message.warning(({content:res.msg,duration:6,closable:true}));
                    }
                })
            },
            handleRangeChange(val) {
                this.searchParams.taskTime_begin = val[0]
                this.searchParams.taskTime_end = val[1]
            },
            //精度任务A/G导出
            exportFile(row,type) {
                const filName = type == 'A' ? 'A系列精度检测任务' : 'G系列精度检测任务'
                this.axios({
                    method: 'get',
                    url: '/dms/dcmAcctestTask/exportFile',
                    responseType: 'blob',
                    params: {
                        type,
                        id: row.id

                    }
                }).then(res => {
                    fileDownload(res, filName + '.xlsx')
                })
            },
            //检测结果
            checkResult(row) {
                this.resultVisible = true;
                this.taskId = row.id
                this.formInline.fileNameA = ''
                this.formInline.fileNameG = ''
                // this.$refs.resultForm.resetFields();
            },
            //A文件上传
            beforeUploadA(file) {
                let reg = /\.(xlsx)|(xls)$/
                if (!file.name.toLowerCase().match(reg)) {
                    this.$Message.warning('请上传excel文件！')
                    this.formInline.fileNameA = ''
                    return false
                }
                let formData = new FormData();
                formData.append("file", file);
                formData.append("dir", 'device')
                let config = {
                    headers: {
                        "Content-Type": "multipart/form-data"
                    }
                };
                this.axios({
                    method: 'post',
                    url: '/fileServer/upload',
                    data: formData,
                    config,
                }).then(res => {
                    if (res.code == 200) {
                        this.$nextTick(() => {
                            this.formInline.fileNameA = res.data.fileName
                            this.formInline.fileUrlA = res.data.fileUrl
                            this.formInline.filePathA = res.data.filepath
                        })
                    }else {
                        this.$Message.warning(({content: res.msg, duration: 6, closable: true}))
                    }
                }).catch(() => {});
                return false;
            },
            //文件删除
            delFile(type) {
                if (type == 0) {
                    this.formInline.fileNameA = ''
                }else {
                    this.formInline.fileNameG = ''
                }
            },
            //G文件上传
            beforeUploadG(file) {
                let reg = /\.(xlsx)|(xls)$/
                if (!file.name.toLowerCase().match(reg)) {
                    this.$Message.warning('请上传excel文件！')
                    this.formInline.fileNameG = ''
                    return false
                }
                let formData = new FormData();
                formData.append("file", file);
                formData.append("dir", 'device')
                let config = {
                    headers: {
                        "Content-Type": "multipart/form-data"
                    }
                };
                this.axios({
                    method: 'post',
                    url: '/fileServer/upload',
                    data: formData,
                    config,
                }).then(res => {
                    if (res.code == 200) {
                        this.$nextTick(() => {
                            this.formInline.fileNameG = res.data.fileName
                            this.formInline.fileUrlG = res.data.fileUrl
                            this.formInline.filePathG = res.data.filepath
                        })
                    }else {
                        this.$Message.warning(({content: res.msg, duration: 6, closable: true}))
                    }
                }).catch(() => {});
                return false;
            },
            handleCancel() {
                this.resultVisible = false
                this.$refs.resultForm.resetFields();
            },
            handleOk() {
                if (!this.formInline.fileNameA && !this.formInline.fileNameG) {
                    this.$Message.warning(({content: '请任意上传一种文件！', duration: 6, closable: true}))
                    return false
                }
                this.uploadLoading = true
                let params = {
                    attachmentType: this.formInline.fileNameA ? 1 : 2,
                    fileName: this.formInline.fileNameA ? this.formInline.fileNameA : this.formInline.fileNameG,
                    fileUrl: this.formInline.fileNameA ? this.formInline.fileUrlA : this.formInline.fileUrlG,
                    filePath: this.formInline.fileNameA ? this.formInline.filePathA : this.formInline.filePathG,
                    taskId: this.taskId
                }
                this.axios({
                    method: 'post',
                    url: '/dms/dcmAcctestTask/importFile',
                    data: params
                }).then(res => {
                    if (res.code === 200) {
                        this.$Message.success('上传成功！')
                        this.resultVisible = false
                        this.uploadLoading = false
                        this.searchList()
                    }else {
                        this.uploadLoading = false
                        this.$Message.error(({content: res.msg, duration: 6, closable: true}))
                    }
                })

            },
            tabsClick(name) {
                // console.log(name)
                // if (name === 0) {
                //     this.$refs.productConfigComponent.searchBtn();
                // } else  if (name === 1){
                //     console.log(this.$$refs);
                //     this.$refs.boxConfigComponent.searchBtn();
                // }else{
                //     this.$refs.shfitconfigComponent.searchBtn();
                // }
            },
            //分页
            changeNum(){
                this.pageNum = 1;
                this.searchList();
            },
            changePageSize(pageSize) {
                this.pageSize = pageSize;
                this.searchList();
            },
            changePageNum(val){
                this.pageNum = val;
                this.searchList();
            },
            searchList() {
                let params = {
                    pageNo:this.pageNum,
                    pageSize:this.pageSize,
                };
                for (let key in this.searchParams) {
                    if (key === 'orgCode' && this.searchParams['orgCode']) {
                        const arr = this.searchParams[key]
                        const { length, last=length-1 } = arr
                        this.$set(params, key, arr[last])
                    }else {
                        if (this.searchParams[key]) {
                            this.$set(params, key, this.searchParams[key])
                        }
                    }

                }
                this.axios({
                    method: 'get',
                    url: '/dms/dcmAcctestTask/list',
                    params
                }).then(res => {
                    if(res.code === 200){
                        this.data = res.data.list
                        this.total = res.data.total
                    }else{
                        this.$Message.warning(({content:res.msg,duration:6,closable:true}));
                    }
                })
            },
            exportMaintainTask() {
                let params = {};
                for (let key in this.searchParams) {
                    if (this.searchParams[key]) {
                        this.$set(params, key, this.searchParams[key])
                    }
                }
                const filName = '检测任务'
                this.axios({
                    method: 'get',
                    url: '/dms/dcmAcctestTask/export',
                    responseType: 'blob',
                    params: params
                }).then(res => {
                    fileDownload(res, filName + '.xlsx')
                })
            },
            onSelectChange(selection) {
                let arr =  []
                selection.map(item => {
                    arr.push(item.id)
                })
                this.ids = arr
            },
            edit(row) {
                this.detailVisible = true;
                this.getManagementDetail(row.id)
            },
            getManagementDetail(id) {
                this.axios({
                    method: 'get',
                    url: '/dms/dcmAcctestTask/queryById',
                    params: {
                        id
                    }
                }).then(res => {
                    if(res.code === 200){
                        this.detailObj = res.data
                    }else{
                        this.$Message.warning(({content:res.msg,duration:6,closable:true}));
                    }
                })
            },
            changeDetailVisible(flag) {
                this.detailVisible = flag;
            },
            //删除
            deleteRow(row) {
                //点击展示提示删除弹窗
                this.delStatus = 0
                this.delId = row.id
                this.delFaultCodeShowF = true;
            },
            handleBatchDelete() {
                this.delStatus = 1
                this.delFaultCodeShowF = true;
            },
            deleteOk() {
                this.delLoading = true
                if (this.delStatus == 0) {
                    this.axios({
                        method: 'delete',
                        url: '/dms/dcmAcctestTask/delete',
                        params: {
                            id: this.delId,
                        }
                    }).then(res => {
                        if(res.code === 200){
                            this.searchList()
                            this.$Message.success(({content:'删除成功！',duration:2,closable:true}));
                        }else{
                            this.$Message.warning(({content:res.msg,duration:6,closable:true}));
                        }
                    }).finally(() => {
                        this.delFaultCodeShowF = false
                        this.delLoading = false
                    })
                }else {
                    this.axios({
                        method: 'delete',
                        url: '/dms/dcmAcctestTask/deleteBatch',
                        params: {
                            ids: this.ids.toString(),
                        }
                    }).then(res => {
                        if(res.code === 200){
                            this.searchList()
                            this.$Message.success(({content:'批量删除成功！',duration:2,closable:true}));
                        }else{
                            this.$Message.warning(({content:res.msg,duration:6,closable:true}));
                        }
                    }).finally(() => {
                        this.delFaultCodeShowF = false
                        this.delLoading = false
                    })
                }
            },
            //分配
            allot(row) {
                // this.allotVisible = true;
                this.dispatchId = row.id
                this.dispatchStatus = 0
                this.$refs.signleCommonModal.show({},2)
            },
            handleBatchDispatch() {
                let arr = this.data.filter(item => this.ids.includes(item.id)).filter(x => x.taskStatus !=0)
                if (arr.length) {
                    this.$Message.warning(({content: '当前任务已分配检测人,不可重复分配!',duration:6,closable:true}));
                    return false
                }
                this.dispatchStatus = 1
                this.$refs.signleCommonModal.show({},2)
            },
            handleRefresh(userIds) {
                if (this.dispatchStatus == 0) {
                    this.axios({
                        method: 'post',
                        url: '/dms/dcmAcctestTask/distribute',
                        data: {
                            id: this.dispatchId,
                            operateEmpno: userIds.toString()
                        }
                    }).then(res => {
                        if(res.code === 200){
                            this.searchList()
                            this.$Message.success(({content:'分配成功！',duration:2,closable:true}));
                        }else{
                            this.$Message.warning(({content:res.msg,duration:6,closable:true}));
                        }
                    })
                }else {
                    this.axios({
                        method: 'post',
                        url: '/dms/dcmAcctestTask/batchDistribute',
                        data: {
                            ids: this.ids.toString(),
                            operateEmpno: userIds.toString()
                        }
                    }).then(res => {
                        if(res.code === 200){
                            this.searchList()
                            this.$Message.success(({content:'批量分配成功！',duration:2,closable:true}));
                        }else{
                            this.$Message.warning(({content:res.msg,duration:6,closable:true}));
                        }
                    })
                }

            },

        },
    }
</script>

<style scoped lang="scss">
    .project{
        //background: #ffffff;
        height: calc(100vh - 150px);
        .title{
            display: flex;
            justify-content: space-between;
            font-size: 20px;
            padding: 10px;
            border-bottom: 1px solid #dddddd;
            .icon {
                display: flex;
                .creatBtnright {
                    display: flex;
                    align-items: center;
                    font-size: 16px;
                    i {
                        font-size: 36px;
                    }
                }
            }
        }
        .tab {
            height: calc(100% - 100px);
            .ivu-tabs-bar {
                padding-left: 30px;
            }
            .ivu-tabs-tab {
                font-size: 18px;
            }
        }
    }
    .addModal {
        .addProject {
            .modalTitle {
                position: relative;
                span {
                    font-weight: bold;
                    font-size: 20px;
                }
                .label {
                    display: flex;
                    flex-wrap: wrap;
                    .item {
                        display: flex;
                        label {
                            width: 150px;
                            height: 100%;
                            background: #F5F6F7;
                        }
                        & > div {
                            width: 330px;
                        }
                    }
                    .cycle {
                        display: flex;
                        .ivu-form-item-label {
                            width: 150px;
                            height: 100%;
                            background: #F5F6F7;
                        }
                        .ivu-form-item-content {
                            border: 1px solid #EEEEEE;
                            width: 800px;
                            .ivu-checkbox-wrapper {
                                margin-left: 30px;
                            }
                        }
                    }
                }
            }
            .modalTitle::before{
                content: '';
                position: absolute;
                width: 3px;
                height: 20px;
                top: 5px;
                left: -10px;
                background: #187BDB;
            }
            .tab {
                display: flex;
                align-items: center;
                flex-wrap: wrap;
                .icon {
                    border: 1px solid #187BDB;
                    border-radius: 30px;
                    padding: 5px 20px 5px 20px;
                    display: flex;
                    align-items: center;
                    margin-left: 20px;
                    color: #187BDB;
                    i {
                        font-size: 20px;
                        font-weight: bold;
                    }
                }
            }
        }
    }
    .resultModal {
        .uploadItem {
            padding: 10px;
            .checkUpload {
                display: flex;
                align-items: center;
                .uploadName {
                    border: 1px dotted #dddddd;
                    height: 32px;
                    line-height: 32px;
                    border-radius: 6px;
                    margin-left: 10px;
                    font-size: 14px;
                    padding: 0 10px;
                }
            }
        }
    }
    .uploadWrapper {
        width: 100%;
        /*line-height: 48px;*/
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 14px;
        .item-src {
            width: 80%;
            display: inline-block;
            /*line-height: 26px;*/
            color: #187bdb;
            cursor: pointer;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .item-icon {
            width: 20%;
            display: inline-block;
            margin-top: 4px;
        }
    }

</style>
